#include "sdk.h"
#include "scriptsecuritywarningdlg.h"

ScriptSecurityWarningDlg::ScriptSecurityWarningDlg( wxWindow* parent, const wxString& operation, const wxString& command ) {
  wxXmlResource* xml_res = wxXmlResource::Get();
  wxString resPath = ConfigManager::GetDataFolder() + _T( "/脚本配置.xrc" );
  if( !xml_res->Load( resPath ) )  {
    xml_File_lock = false;
    Manager::Get()->GetLogManager()->LogInf( F( _T( "文件丢失: %s " ), resPath.wx_str() ) );
    return;
  }
  if( !xml_res->LoadObject( this, parent, _T( "ScriptingSecurityDlg" ), _T( "wxScrollingDialog" ) ) ) {
    xml_File_lock = false;
    Manager::Get()->GetLogManager()->LogInf( _T( "资源丢失" ) );
    return;
  }
  xml_File_lock = true;
  XRCCTRL( *this, "wxID_OK", wxButton )->SetDefault();
  wxColour c = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
  XRCCTRL( *this, "txtCommand", wxTextCtrl )->SetBackgroundColour( c );
  XRCCTRL( *this, "lblOperation", wxStaticText )->SetLabel( _T( "Operation: " ) + operation );
  XRCCTRL( *this, "txtCommand", wxTextCtrl )->SetValue( command );
}

ScriptSecurityWarningDlg::~ScriptSecurityWarningDlg() {
}

ScriptSecurityResponse ScriptSecurityWarningDlg::GetResponse() {
  return ( ScriptSecurityResponse )XRCCTRL( *this, "cmbAnswer", wxComboBox )->GetSelection();
}

void ScriptSecurityWarningDlg::EndModal( int retCode ) {
  wxScrollingDialog::EndModal( retCode );
}
